// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 < 0.9.0; contract converter { function stringToBytes32(string memory source) public pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } }