Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

ChaCha streaming cipher

$
0
0
this is a C chacha library as a vb compatible dll
also an example on working with SafeArrays between C and VB

symmetric so you just call it again to decrypt.
I compiled with vs2008, release size 42k

repo here: https://github.com/dzzie/libs/tree/master/libChaCha

Example usage:
Code:

Private Declare Sub chainit Lib "libchacha" (ByVal key As String, ByVal klen As Long, ByVal counter As Long)
Private Declare Function chacha Lib "libchacha" (ByRef buf() As Byte) As Byte()

    Dim b() As Byte
    Dim bOut() As Byte
    dim cnt as long

    'todo: load b() with your data..

    chainit txtPass, Len(txtPass), cnt
    bOut() = chacha(b)
   
    If AryIsEmpty(bOut) Then
        txtCrypt = "Encryption Failed!"
        Exit Sub
    End If

ChaCha implementation license
Code:

/*
Copyright (C) 2014 insane coder (http://insanecoding.blogspot.com/, http://chacha20.insanecoding.org/)

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

This implementation is intended to be simple, many optimizations can be performed.
*/

Attached Files

Viewing all articles
Browse latest Browse all 1529

Trending Articles