Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
renames XChaCha20Poly1305 to XChaCha20Poly1305Ietf
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Zwikstra committed Aug 20, 2018
1 parent 65e2169 commit d2d8dc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions example/lib/main.dart
Expand Up @@ -165,33 +165,33 @@ assert(valid);''', () async {
'Combined mode',
'The authentication tag is directly appended to the encrypted message.',
'''// Generate random nonce and key
var nonce = await XChaCha20Poly1305.generateNonce();
var key = await XChaCha20Poly1305.generateKey();
var nonce = await XChaCha20Poly1305Ietf.generateNonce();
var key = await XChaCha20Poly1305Ietf.generateKey();
// Encrypt
var msg = 'hello world';
var data = '123456';
var ciphertext = await XChaCha20Poly1305.encrypt(msg, data, nonce, key);
var ciphertext = await XChaCha20Poly1305Ietf.encrypt(msg, data, nonce, key);
print(hex.encode(ciphertext));
// Decrypt
var decrypted = await XChaCha20Poly1305.decrypt(ciphertext,data, nonce, key);
var decrypted = await XChaCha20Poly1305Ietf.decrypt(ciphertext,data, nonce, key);
assert(msg == decrypted);''', () async {
// Generate random nonce and key
var nonce = await XChaCha20Poly1305.generateNonce();
var key = await XChaCha20Poly1305.generateKey();
var nonce = await XChaCha20Poly1305Ietf.generateNonce();
var key = await XChaCha20Poly1305Ietf.generateKey();

// Encrypt
var msg = 'hello world';
var data = '123456';
var ciphertext =
await XChaCha20Poly1305.encrypt(msg, data, nonce, key);
await XChaCha20Poly1305Ietf.encrypt(msg, data, nonce, key);

// Decrypt
var decrypted =
await XChaCha20Poly1305.decrypt(ciphertext, data, nonce, key);
await XChaCha20Poly1305Ietf.decrypt(ciphertext, data, nonce, key);

assert(msg == decrypted);

Expand All @@ -201,33 +201,33 @@ assert(msg == decrypted);''', () async {
'Detached mode',
'Returns the encrypted message and authentication tag as seperate entities.',
'''// Generate random nonce and key
var nonce = await XChaCha20Poly1305.generateNonce();
var key = await XChaCha20Poly1305.generateKey();
var nonce = await XChaCha20Poly1305Ietf.generateNonce();
var key = await XChaCha20Poly1305Ietf.generateKey();
// Encrypt
var msg = 'hello world';
var data = '123456';
var encrypted = await XChaCha20Poly1305.encryptDetached(msg, data, nonce, key);
var encrypted = await XChaCha20Poly1305Ietf.encryptDetached(msg, data, nonce, key);
print('cipher: \${encrypted.cipher}');
print('mac: \${encrypted.mac}');
// Decrypt
var decrypted = await XChaCha20Poly1305.decryptDetached(encrypted, data, nonce, key);
var decrypted = await XChaCha20Poly1305Ietf.decryptDetached(encrypted, data, nonce, key);
assert(msg == decrypted);''', () async {
// Generate random nonce and key
var nonce = await XChaCha20Poly1305.generateNonce();
var key = await XChaCha20Poly1305.generateKey();
var nonce = await XChaCha20Poly1305Ietf.generateNonce();
var key = await XChaCha20Poly1305Ietf.generateKey();

// Encrypt
var msg = 'hello world';
var data = '123456';
var encrypted =
await XChaCha20Poly1305.encryptDetached(msg, data, nonce, key);
await XChaCha20Poly1305Ietf.encryptDetached(msg, data, nonce, key);

// Decrypt
var decrypted = await XChaCha20Poly1305.decryptDetached(
var decrypted = await XChaCha20Poly1305Ietf.decryptDetached(
encrypted, data, nonce, key);

assert(msg == decrypted);
Expand Down
2 changes: 1 addition & 1 deletion flutter_sodium.code-workspace
Expand Up @@ -8,6 +8,6 @@
}
],
"settings": {
"java.configuration.updateBuildConfiguration": "interactive"
"java.configuration.updateBuildConfiguration": "automatic"
}
}
2 changes: 1 addition & 1 deletion lib/flutter_sodium.dart
Expand Up @@ -19,7 +19,7 @@ export 'src/sealed_box.dart';
export 'src/secret_box.dart';
export 'src/session_keys.dart';
export 'src/short_hash.dart';
export 'src/x_cha_cha20_poly1305.dart';
export 'src/x_cha_cha20_poly1305_ietf.dart';

/// Sodium is a modern, easy-to-use software library for encryption, decryption, signatures, password hashing and more.
///
Expand Down
Expand Up @@ -4,7 +4,7 @@ import 'dart:convert';
import '../flutter_sodium.dart';

/// The XChaCha20-Poly1305 construction
class XChaCha20Poly1305 {
class XChaCha20Poly1305Ietf {
/// Generates a random key for use with the XChaCha20-Poly1305 construction.
static Future<Uint8List> generateKey() =>
Sodium.cryptoAeadXchacha20poly1305IetfKeygen();
Expand Down

0 comments on commit d2d8dc6

Please sign in to comment.