can now encrypt strings in cli menu
This commit is contained in:
parent
c6325a9925
commit
27db4aec17
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||||
|
<PackageReference Include="NicewareSecure" Version="0.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using Sodium;
|
using Sodium;
|
||||||
|
using niceware;
|
||||||
|
|
||||||
|
using chestcrypto.simplepack;
|
||||||
|
using chestcrypto.symmetric;
|
||||||
|
|
||||||
using treasurechest.STDIOWrapper;
|
using treasurechest.STDIOWrapper;
|
||||||
using getpass;
|
|
||||||
|
|
||||||
namespace treasurechestCLI{
|
namespace treasurechestCLI{
|
||||||
|
|
||||||
@ -11,7 +16,7 @@ namespace treasurechestCLI{
|
|||||||
int choice = 0;
|
int choice = 0;
|
||||||
int counter = 1;
|
int counter = 1;
|
||||||
byte[] key = new byte[32];
|
byte[] key = new byte[32];
|
||||||
string message;
|
byte[] message;
|
||||||
string encrypted;
|
string encrypted;
|
||||||
|
|
||||||
translations.Strings strings = new translations.Strings();
|
translations.Strings strings = new translations.Strings();
|
||||||
@ -48,13 +53,19 @@ namespace treasurechestCLI{
|
|||||||
}
|
}
|
||||||
if (choice == 1){
|
if (choice == 1){
|
||||||
try {
|
try {
|
||||||
message = GetMessage.getTypedMessage();
|
message = UTF8Encoding.UTF8.GetBytes(GetMessage.getTypedMessage());
|
||||||
}
|
}
|
||||||
catch(System.NullReferenceException){
|
catch(System.NullReferenceException){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
key = SecretBox.GenerateKey();
|
key = SecretBox.GenerateKey();
|
||||||
//encrypted =
|
encrypted = SimplePack.pack(Symmetric.encrypt(message, key));
|
||||||
|
STDIO.O(encrypted);
|
||||||
|
foreach (string word in Niceware.ToPassphrase(key)){
|
||||||
|
Console.Write(word + " ");
|
||||||
|
}
|
||||||
|
STDIO.O("");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (choice == encryptMenuOptions.Length){
|
else if (choice == encryptMenuOptions.Length){
|
||||||
|
@ -43,7 +43,6 @@ namespace DoubleKeyPrivateTests
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
||||||
Console.WriteLine("Throws properly for too small array size");
|
|
||||||
}
|
}
|
||||||
if (success){
|
if (success){
|
||||||
Assert.Fail();
|
Assert.Fail();
|
||||||
@ -54,7 +53,6 @@ namespace DoubleKeyPrivateTests
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
||||||
Console.WriteLine("Throws properly for too large array size");
|
|
||||||
}
|
}
|
||||||
if (success){
|
if (success){
|
||||||
Assert.Fail();
|
Assert.Fail();
|
||||||
|
@ -26,7 +26,6 @@ namespace DoubleKeyPublicTests
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
||||||
Console.WriteLine("Throws properly for too small array size");
|
|
||||||
}
|
}
|
||||||
if (success){
|
if (success){
|
||||||
Assert.Fail();
|
Assert.Fail();
|
||||||
@ -37,7 +36,6 @@ namespace DoubleKeyPublicTests
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
catch (chestcrypto.exceptions.InvalidDoubleKeyException){
|
||||||
Console.WriteLine("Throws properly for too large array size");
|
|
||||||
}
|
}
|
||||||
if (success){
|
if (success){
|
||||||
Assert.Fail();
|
Assert.Fail();
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
namespace chestcrypto{
|
|
||||||
|
|
||||||
namespace simplepack{
|
|
||||||
|
|
||||||
public class Packed{
|
|
||||||
//private string
|
|
||||||
//public override string ToString(){
|
|
||||||
//}
|
|
||||||
public Packed(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -7,7 +7,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Base58Check" Version="0.2.0" />
|
<PackageReference Include="Base58Check" Version="0.2.0" />
|
||||||
<PackageReference Include="MessagePack" Version="2.1.115" />
|
<PackageReference Include="MessagePack" Version="2.1.115" />
|
||||||
<PackageReference Include="niceware" Version="0.1.0.1" />
|
|
||||||
<PackageReference Include="Sodium.Core" Version="1.2.3" />
|
<PackageReference Include="Sodium.Core" Version="1.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user