writer.write(outfile) outfile.close() ### Example 9: Encryption test, using an external .key file # This creates two files: encrypted_external_regcode.mdx and encrypted_external_regcode.key. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_external_regcode.mdx", "wb") writer = MDictWriter(d, "Encrypted dictionary", "This dictionary tests encryption", encoding="utf8", version="2.0", encrypt_key=b"my password") writer.write(outfile) outfile.close() key = encrypt_key(b"my password", "*****@*****.**".encode("ascii")) keyfile = io.open("example_output/encrypted_external_regcode.key", "w", encoding="ascii") keyfile.write(key) keyfile.close() ### Example 10: Encryption test, with the registration code supplied with the dictionary. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_internal_regcode.mdx", "wb") writer = MDictWriter(d, "Encrypted dictionary", "This dictionary tests encryption, with key supplied in dictionary header", encoding="utf8", version="2.0", encrypt_key=b"abc", user_email="*****@*****.**".encode("ascii")) writer.write(outfile)
outfile.close() ### Example 9: Encryption test, using an external .key file, and the user email. # This creates two files: encrypted_external_regcode.mdx and encrypted_external_regcode.key. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_external_regcode.mdx", "wb") writer = MDictWriter(d, "Encrypted dictionary", "This dictionary tests encryption", encoding="utf16", version="2.0", encrypt_key=b"abc", register_by="email") writer.write(outfile) outfile.close() key = encrypt_key(b"abc", email="*****@*****.**") keyfile = io.open("example_output/encrypted_external_regcode.key", "w", encoding="ascii") keyfile.write(key) keyfile.close() ### Example 10: Encryption test, with the registration code supplied with the dictionary. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_internal_regcode.mdx", "wb") writer = MDictWriter(d, "Encrypted dictionary", "This dictionary tests encryption, with key supplied in dictionary header", encoding="utf16", version="2.0", encrypt_key=b"abc", register_by="email", user_email="*****@*****.**")
outfile.close() ### Example 9: Encryption test, using an external .key file, and the user email. # This creates two files: encrypted_external_regcode.mdx and encrypted_external_regcode.key. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_external_regcode.mdx", "wb") writer = MDictWriter(d, "Encrypted dictionary", "This dictionary tests encryption", encoding="utf16", version="2.0", encrypt_key=b"abc", register_by="email") writer.write(outfile) outfile.close() key = encrypt_key(b"abc", email="*****@*****.**") keyfile = io.open("example_output/encrypted_external_regcode.key", "w", encoding="ascii") keyfile.write(key) keyfile.close() ### Example 10: Encryption test, with the registration code supplied with the dictionary. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_internal_regcode.mdx", "wb") writer = MDictWriter( d, "Encrypted dictionary", "This dictionary tests encryption, with key supplied in dictionary header", encoding="utf16", version="2.0",
### Example 9: Encryption test, using an external .key file # This creates two files: encrypted_external_regcode.mdx and encrypted_external_regcode.key. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_external_regcode.mdx", "wb") writer = MDictWriter( d, "Encrypted dictionary", "This dictionary tests encryption", encoding="utf8", version="2.0", encrypt_key=b"my password", ) writer.write(outfile) outfile.close() key = encrypt_key(b"my password", "*****@*****.**".encode("ascii")) keyfile = io.open("example_output/encrypted_external_regcode.key", "w", encoding="ascii") keyfile.write(key) keyfile.close() ### Example 10: Encryption test, with the registration code supplied with the dictionary. # To open, the user needs to set his/her email to "*****@*****.**" in the MDict reader. outfile = open("example_output/encrypted_internal_regcode.mdx", "wb") writer = MDictWriter( d, "Encrypted dictionary", "This dictionary tests encryption, with key supplied in dictionary header", encoding="utf8", version="2.0", encrypt_key=b"abc", user_email="*****@*****.**".encode("ascii"),