import hashlib - import hashlib
def blake2b_hash(data): - # Create a new BLAKE2b hash object
- h = hashlib.blake2b()
- # Update the hash object with the input data
- h.update(data.encode())
- # Get the hexadecimal representation of the hash
- hex_hash = h.hexdigest()
- return hex_hash
- data = "example data to hash"
- print("BLAKE2b Hash:", blake2b_hash(data))
- .
- Siz ushbu funksiyadan istalgan turdagi maʼlumotlarni xeshlash uchun foydalanishingiz mumkin, shunchaki xeshlanmoqchi boʻlgan maʼlumotlarni funksiyaga satr sifatida oʻtkazing va u xeshning oʻn oltilik koʻrinishini qaytaradi.
- Shuni ta'kidlash kerakki, BLAKE2 nisbatan yangi xesh-funksiya bo'lib, u juda tez va xavfsiz xesh-funksiya hisoblanadi, u IETF tomonidan ham standartlashtirilgan va zamonaviy tizimlarda yaxshi tanlov hisoblanadi.
- Ushbu heshlash Python dasturlash tilida BLAKE2
- HESHLASH MUXITIDA QILINDI
- #include
- #include
- #include
- #include
- #include
- #include
- #include
std::string blake2b_hash(const std::string& data) { - std::stringstream ss;
- std::vector hash(BLAKE2B_OUTBYTES);
- blake2b(hash.data(), data.c_str(), NULL, hash.size(), data.size(), 0);
- for (unsigned char i : hash) {
- ss << std::hex << (int)i; }return ss.str();}
int main() { - std::string data = "example data to hash";
- std::string hash = blake2b_hash(data);
- std::cout << "BLAKE2b Hash: " << hash << std::endl;
- return 0;}
Javada SHA-256 heshlash kodi: - import java.security.MessageDigest;
- public class HashExample {
- public static String sha256(String data) {
- try {
- MessageDigest digest = MessageDigest.getInstance("SHA-256");
- byte[] hash = digest.digest(data.getBytes("UTF-8"));
- StringBuffer hexString = new StringBuffer();
- for (int i = 0; i < hash.length; i++) {
- String hex = Integer.toHexString(0xff & hash[i]);
- if(hex.length() == 1) hexString.append('0');
- hexString.append(hex);
- }
- return hexString.toString();
- } catch(Exception ex){
- throw new RuntimeException(ex);
- }
- }
- public static void main(String[] args) {
- String data = "example data to hash";
- String hash = sha256(data);
- System.out.println("SHA-256 Hash: " + hash);
- }
- }
Do'stlaringiz bilan baham: |