www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Encryption

reply noid <bielsalamimo gmail.com> writes:
Hi! I am pretty new on Dlang and I wanted to make a small 
password manager that used some sort of encryption on a file (for 
example AES256) and save a password to decrypt it later, so you 
can copy the password.
I couldn't find any way of doing encryption on Dlang, is there a 
lib that's better for doing this? Secured and some other libs i 
tried didn't quite work.
I also don't know how I could store the password (for example in 
a SHA256 hash) for decrypting the files.
May 17 2021
next sibling parent reply mw <mingwu gmail.com> writes:
On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote:
 Hi! I am pretty new on Dlang and I wanted to make a small 
 password manager that used some sort of encryption on a file 
 (for example AES256) and save a password to decrypt it later, 
 so you can copy the password.
 I couldn't find any way of doing encryption on Dlang, is there 
 a lib that's better for doing this? Secured and some other libs 
 i tried didn't quite work.
 I also don't know how I could store the password (for example 
 in a SHA256 hash) for decrypting the files.
https://code.dlang.org/search?q=SHA
May 17 2021
parent noid <bielsalamimo gmail.com> writes:
On Monday, 17 May 2021 at 16:59:28 UTC, mw wrote:
 On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote:
 Hi! I am pretty new on Dlang and I wanted to make a small 
 password manager that used some sort of encryption on a file 
 (for example AES256) and save a password to decrypt it later, 
 so you can copy the password.
 I couldn't find any way of doing encryption on Dlang, is there 
 a lib that's better for doing this? Secured and some other 
 libs i tried didn't quite work.
 I also don't know how I could store the password (for example 
 in a SHA256 hash) for decrypting the files.
https://code.dlang.org/search?q=SHA
okay thanks i'll take a look at those libs but what about AES256? the crypto lib gave me some errors every time i ran "dub run" about the crypto lib "cannot call impure function 'core.bitop.volatileStore'"
May 17 2021
prev sibling next sibling parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote:
 Hi! I am pretty new on Dlang and I wanted to make a small 
 password manager that used some sort of encryption on a file 
 (for example AES256) and save a password to decrypt it later, 
 so you can copy the password.
 I couldn't find any way of doing encryption on Dlang, is there 
 a lib that's better for doing this? Secured and some other libs 
 i tried didn't quite work.
 I also don't know how I could store the password (for example 
 in a SHA256 hash) for decrypting the files.
https://code.dlang.org/search?q=crypto
May 17 2021
parent reply noid <bielsalamimo gmail.com> writes:
On Monday, 17 May 2021 at 17:03:39 UTC, Imperatorn wrote:
 On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote:
 Hi! I am pretty new on Dlang and I wanted to make a small 
 password manager that used some sort of encryption on a file 
 (for example AES256) and save a password to decrypt it later, 
 so you can copy the password.
 I couldn't find any way of doing encryption on Dlang, is there 
 a lib that's better for doing this? Secured and some other 
 libs i tried didn't quite work.
 I also don't know how I could store the password (for example 
 in a SHA256 hash) for decrypting the files.
https://code.dlang.org/search?q=crypto
crypto prints the error i just posted last post, botan lib gives me this error: ``` /home/anon/.dub/packages/memutils-1.0.4/memutils/source/memutils/utils.d:65:18: error: class botan.cert.x509.x509cert.X509CertificateImpl member init is not accessible 65 | return cast(TR)T.init; | ^ /home/anon/.dub/packages/memutils-1.0.4/memutils/source/memutils/utils.d:65:18: error: function botan.cert.x509.x509_obj.X509Object.init (RefCounted!(DataSourceImpl, AppMem) input, const(string) labels) is not callable using argument types () 65 | return cast(TR)T.init; | ^ /home/anon/.dub/packages/memutils-1.0.4/memutils/source/memutils refcounted.d:31:52: error: template instance memutils.utils.ObjectAllocator!(X509CertificateImpl, ThreadMem).alloc!() error instantiating 31 | ret.m_object = ObjectAllocator!(T, ALLOC).alloc(args); | ^ /home/anon/.dub/packages/memutils-1.0.4/memutils/source/memutils/ efcounted.d:199:29: note: instantiated from here: opCall!() 199 | auto newObj = this.opCall(); | ^ /home/anon/.dub/packages/botan-1.12.19/botan/source/botan/cert/x5 9/x509cert.d:41:25: note: instantiated from here: RefCounted!(X509CertificateImpl, ThreadMem) 41 | alias X509Certificate = RefCounted!X509CertificateImpl; | ^ /home/anon/.dub/packages/botan-1.12.19/botan/source/botan/constants.d:98:73: error: static assert (BOTAN_HAS_SIMD) is false 98 | version(SIMD_SSE2) { enum BOTAN_HAS_SIMD_SSE2 = true; static assert(BOTAN_HAS_SIMD); } | ^ /usr/bin/gdc failed with exit code 1. ```
May 17 2021
parent mw <mingwu gmail.com> writes:
On Monday, 17 May 2021 at 17:08:41 UTC, noid wrote:
 On Monday, 17 May 2021 at 17:03:39 UTC, Imperatorn wrote:
 On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote:
 Hi! I am pretty new on Dlang and I wanted to make a small 
 password manager that used some sort of encryption on a file 
 (for example AES256) and save a password to decrypt it later, 
 so you can copy the password.
 I couldn't find any way of doing encryption on Dlang, is 
 there a lib that's better for doing this? Secured and some 
 other libs i tried didn't quite work.
 I also don't know how I could store the password (for example 
 in a SHA256 hash) for decrypting the files.
https://code.dlang.org/search?q=crypto
crypto prints the error i just posted last post, botan lib gives me this error:
Try different compiler options (version=??? to make the static assert true). If still not working, log an issue on the library's git repo page.
May 17 2021
prev sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote:
 Hi! I am pretty new on Dlang and I wanted to make a small 
 password manager that used some sort of encryption on a file 
 (for example AES256) and save a password to decrypt it later, 
 so you can copy the password.
I haven't done this specifically myself, but if I did, I'd probably use bindings to the C libsodium and let it do most the encryption work. this looks reasonable but again I haven't used myself. https://code.dlang.org/packages/libsodiumd Since it is a simple binding to the C library, you'd use it the same way you would from C itself and can look up tutorials for that and easily translate to D.
 I also don't know how I could store the password (for example 
 in a SHA256 hash) for decrypting the files.
Now this I have done myself, and again, I delegated the real work to a C library called argon2. My library is https://code.dlang.org/packages/arsd-official%3Aargon2 And my docs: http://arsd-official.dpldocs.info/arsd.argon2.html If you get the C argon2 library installed, then you can use that D module easily with the `encode` and `verify` functions.
May 17 2021