Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9271659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:40:31+00:00 2026-06-18T15:40:31+00:00

Is there an AES encryption library for clojure? should I use a java libray

  • 0

Is there an AES encryption library for clojure? should I use a java libray available through maven or clojars? Thank your for your time and consideration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:40:32+00:00Added an answer on June 18, 2026 at 3:40 pm

    Here is a perhaps more idiomatic example using the available java crypto libraries. encrypt and decrypt here each simply take input text and the encryption key, both as Strings.

    (import (javax.crypto Cipher KeyGenerator SecretKey)
            (javax.crypto.spec SecretKeySpec)
            (java.security SecureRandom)
            (org.apache.commons.codec.binary Base64))
    
    (defn bytes [s]
      (.getBytes s "UTF-8"))
    
    (defn base64 [b]
      (Base64/encodeBase64String b))
    
    (defn debase64 [s]
      (Base64/decodeBase64 (bytes s)))
    
    (defn get-raw-key [seed]
      (let [keygen (KeyGenerator/getInstance "AES")
            sr (SecureRandom/getInstance "SHA1PRNG")]
        (.setSeed sr (bytes seed))
        (.init keygen 128 sr)
        (.. keygen generateKey getEncoded)))
    
    (defn get-cipher [mode seed]
      (let [key-spec (SecretKeySpec. (get-raw-key seed) "AES")
            cipher (Cipher/getInstance "AES")]
        (.init cipher mode key-spec)
        cipher))
    
    (defn encrypt [text key]
      (let [bytes (bytes text)
            cipher (get-cipher Cipher/ENCRYPT_MODE key)]
        (base64 (.doFinal cipher bytes))))
    
    (defn decrypt [text key]
      (let [cipher (get-cipher Cipher/DECRYPT_MODE key)]
        (String. (.doFinal cipher (debase64 text)))))
    

    Used suchwise:

    (def key "secret key")
    (def encrypted (encrypt "My Secret" key)) ;; => "YsuYVJK+Q6E36WjNBeZZdg=="
    (decrypt encrypted key) ;; => "My Secret"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a library available for AES 256-bits encryption in Javascript?
I use AES encryption. It's ok when I encrypt and then decrypt whole file.
I use AES encryption with the Rijndael class to encrypt passwords and then store
I currently have a set of AES Encryption/Decryption functions that I use in ASP.NET
AES seems like a relatively quick way to do strong encryption and there are
I'm implementing encryption / decryption using Java Cipher and AES. Everything is working well
I want to use AES encryption in my application. I have come across some
Possible Duplicate: Javascript AES encryption Is there a way to validate an AES encrypted
I want to create a key for use in AES encryption. I found a
Any recommendations on an AES encryption library that's compatible with Python 2.7 for Windows?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.