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 8139183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:44:25+00:00 2026-06-06T11:44:25+00:00

I have two separated applications, one written in Java and other in Erlang. Both

  • 0

I have two separated applications, one written in Java and other in Erlang.
Both applications send messages to each other in String format, and those messages are encrypted in the Java app and need to be decrypted in the Erlang app.

The problem is this:
I’m using RSA public/private keys to do the encryption/decryption.

If I encrypt the data and decrypt all inside the my Erlang code, everything is fine. But, I’m not able to decrypt the string coming from my java endpoint.

Here’s a simple test I’m doing:

PrivKey = "-----BEGIN RSA PRIVATE KEY----- ...",
% Data is the string I receive from Java
Data = "s013aA/SGN2iGYEbEIXXKvJiipqisRVfVEDneL8npRgThTHxTnYZESzVfCF463phPZyo5aOozisU7pwDdGKXgY8aqYZC+a3uES5muTb2RrzJ17yYku+g4S44vgIwZ9EyustZafNVGEYfgbWOYaPP/q5k683uR+MRHVqp6UbqMok=",
[PrivEntry] = public_key:pem_decode(list_to_binary(PrivKey)),
Priv = public_key:pem_entry_decode(PrivEntry),
BinData = iolist_to_binary(Data),
public_key:decrypt_private(Data, Priv).

Executing this code generates an error like this:

** exception error: decrypt_failed

I think the problem is in the format of BinData, but I couldn’t find any place saying how I encode a string to pass to decrypt_private function.

Does anyone knows how to do this? This seems simple, but is taking me a lot of time to figure out.

Thanks.

  • 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-06T11:44:27+00:00Added an answer on June 6, 2026 at 11:44 am

    After digging a little bit more, I found the answer!
    I needed to decode my string into a base64 binary.

    PrivKey = "-----BEGIN RSA PRIVATE KEY----- ...",
    % Data is the string I receive from Java
    Data = "s013aA/SGN2iGYEbEIXXKvJiipqisRVfVEDneL8npRgThTHxTnYZESzVfCF463phPZyo5aOozisU7pwDdGKXgY8aqYZC+a3uES5muTb2RrzJ17yYku+g4S44vgIwZ9EyustZafNVGEYfgbWOYaPP/q5k683uR+MRHVqp6UbqMok=",
    [PrivEntry] = public_key:pem_decode(list_to_binary(PrivKey)),
    Priv = public_key:pem_entry_decode(PrivEntry),
    
    BinData = base64:decode(Data), %<-- THIS IS THE MAGIC
    
    public_key:decrypt_private(BinData, Priv).
    

    Hope this helps other people.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two anchored images on top of each other, separated with a line
I have two separate applications (both part of the same system) that share a
I have a system that has three applications (one windows application and two web
I have two applications developed in VS2010 (C#, .NET 4.0) - each is a
I have two separate .NET applications, one server and another WinForms. WinForms app has
I have a product with two targets, one for iPhone and the other for
We have two separate web applications for a site: One for the site itself,
I have two applications setup in IIS7.5. MVC 3 is installed. One application serves
I have two essentially separate applications for configuring two pieces of hardware sold by
I have two heroku accounts with two seperate applications. I am new at this

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.