generateSHA1Hash static method
Implementation
static String generateSHA1Hash(String input) {
final bytes = utf8.encode(input);
var hash = 0;
for (final byte in bytes) {
hash = ((hash << 5) - hash + byte) & 0xFFFFFFFF;
}
// Generate 32 characters for UUID compatibility
var result = hash.abs().toRadixString(16).padLeft(8, '0');
// Extend to 32 characters by repeating and modifying the hash
for (int i = 8; i < 32; i++) {
hash = ((hash * 1103515245 + 12345) & 0x7fffffff);
result += (hash % 16).toRadixString(16);
}
return result.substring(0, 32); // Ensure exactly 32 characters
}