Giter Club home page Giter Club logo

aes.vbs's Issues

Error on windows server 2019

The line Set aes = CreateObject ("System.Security.Cryptography.RijndaelManaged") gives the following error
(null): 0x80131509

I run this command to check class. Everything is regular.
powershell -Command [System.Reflection.Assembly] :: GetAssembly ('System.Security.Cryptography.RijndaelManaged')

GAC Version Location


True v4.0.30319 C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ mscorlib.dll

How can I solve?

Modified code for AES ECB

Hi, very impressed with your code package and i was looking for AES in ECB mode, because the end system i connect is using 128 - ECB AES algorithm to decrypt, so i should encrypt with same. I have end up with below code and i would like to have "text to encrypt" and "key" as parameter, no IV or no MAC required.

I am expecting something like this

Set utf8 = CreateObject("System.Text.UTF8Encoding")
aesKeyBytes = B64Decode(aesKey)
Set aesEnc = AES.CreateEncryptor_2((aesKeyBytes)) ' without IV - but not sure about the syntax
plainBytes = utf8.GetBytes_4(plaintext)
cipherBytes = aesEnc .TransformFinalBlock((plainBytes), 0, UBound(plainBytes))
Encrypt = B64Encode(cipherBytes)

Complete code:

Function Min(a, b)
    Min = a
    If b < a Then Min = b
End Function

Function B64Encode(bytes)
    Dim result As String
    Dim b64Block() As Byte
    Dim b64Enc As Object
    Dim utf8 As Object
    Dim Offset, Length, BlockSize As Integer
    
    Set b64Enc = CreateObject("System.Security.Cryptography.ToBase64Transform")
    Set utf8 = CreateObject("System.Text.UTF8Encoding")
    BlockSize = b64Enc.InputBlockSize
    For Offset = 0 To LenB(bytes) - 1 Step BlockSize
        Length = Min(BlockSize, UBound(bytes) - Offset)
        b64Block = b64Enc.TransformFinalBlock((bytes), Offset, Length)
        result = result & utf8.GetString((b64Block))
    Next
    B64Encode = result
End Function

Function B64Decode(b64Str)
    Dim utf8 As Object
    Dim bytes() As Byte
    Dim b64Dec As Object
    
    Set utf8 = CreateObject("System.Text.UTF8Encoding")
    Set b64Dec = CreateObject("System.Security.Cryptography.FromBase64Transform")
    bytes = utf8.GetBytes_4(b64Str)
    B64Decode = b64Dec.TransformFinalBlock((bytes), 0, UBound(bytes))
End Function

Function Encrypt(plaintext, aesKey)
    Dim aesKeyBytes, cipherBytes, plainBytes() As Byte
    Dim aesEnc As Object
    Dim utf8 As Object
    Dim AES As Object
    Dim aesIV() As Byte
    Set AES = CreateObject("System.Security.Cryptography.RijndaelManaged")
   
    Set utf8 = CreateObject("System.Text.UTF8Encoding")
    'Set aesIV = AES.GenerateIV
    aesKeyBytes = B64Decode(aesKey)
    'Set aesEnc = AES.CreateEncryptor_2((aesKeyBytes), aesIV)
    plainBytes = utf8.GetBytes_4(plaintext)
    cipherBytes = AES.CreateEncryptor.TransformFinalBlock((plainBytes), 0, UBound(plainBytes))
    Encrypt = B64Encode(cipherBytes)
End Function

Excel - how implement as formulas?

Hello.

How use aes.vbs to create Excel formulas?

General I have HEX 128 bits AES CBC data like this:

063195FB35FD19DAC4C6DCD4ED773A36

the key is (also in HEX, general is deferential but in my example use zeros only) :

00000000000000000000000000000000

result is

2E026256917E06C38D6FAB8F92A0A028

Understood that in Excel press ALT+F11 (dev window), insert new module, paste code but what next? Sorry, I'm not a developer, something know but rather I'm end user that need decode thousands values like about data. Can someone help please.

BR, Krzysiek

the script is not working in WinPE

Hello,
thanks for the great script but I tried it in WinPE and it's not working, it failed at the first line and gave error, please advise
Set utf8 = CreateObject("System.Text.UTF8Encoding")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.