importbase64fromcryptography.hazmat.primitivesimportserializationfromcryptography.hazmat.primitives.asymmetricimported25519defgenerate_ed25519_keypair(private_key_filename:str="private.key",public_key_filename:str="public.pub")-> None:"""Generate Ed25519 Keys Pairs. Args: private_key_filename(default private.key): private key filename as a string. public_key_filename(default public.pub): public key filename as a string Returns: """private_key=ed25519.Ed25519PrivateKey.generate()public_key=private_key.public_key()private_key_str=private_key.private_bytes(encoding=serialization.Encoding.Raw,format=serialization.PrivateFormat.Raw,encryption_algorithm=serialization.NoEncryption(),)print("Private Key:\t",base64.urlsafe_b64encode(private_key_str))public_key_str=public_key.public_bytes(encoding=serialization.Encoding.Raw,format=serialization.PublicFormat.Raw)print("Public Key:\t",base64.urlsafe_b64encode(public_key_str))withopen(private_key_filename,"wb")asfp:fp.write(base64.urlsafe_b64encode(private_key_str))print(f"Private Key is written to:\t{private_key_filename}")withopen(public_key_filename,"wb")asfp:fp.write(base64.urlsafe_b64encode(public_key_str))print(f"Public Key is written to:\t{public_key_filename}")
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-21 UTC。"],[],[]]