// E2E 测试：crypto 模块
import * as crypto from "crypto";

function main(): number {
    // Test createHash('sha256')
    let hash = crypto.createHash("sha256");
    hash.update("hello");
    let digest = hash.digest("hex");
    print("sha256 digest: " + digest);

    // Test createHash('md5')
    let md5hash = crypto.createHash("md5");
    md5hash.update("hello");
    let md5digest = md5hash.digest("hex");
    print("md5 digest: " + md5digest);

    // Test randomBytes()
    let bytes = crypto.randomBytes(16);
    print("randomBytes length: " + bytes.length);

    if (bytes.length == 16) {
        return 1;
    }
    return 0;
}
