Convert Ethereum bytes32 hexadecimal to Solana address format - type-conversion

how can I convert the recipient '0x1d7030efa359a07737d690157e8c4bb853772d33378f0fd3e6601b47ed0f02b5' which is in bytes32 to a string basically it should be a Solana address (Base-58). Not able to figure out the conversion. Thanks!
Transaction hash: https://etherscan.io/tx/0xf39aed88f313a820c45e35b81defcdb185cc70e755283d6f1b9146fd6b9b8d44[enter image description here](https://i.stack.imgur.com/vTCux.png)
I tried using solana-address-codec package, it's not working.

try
b.toBase58()
from this library

Related

How to parse json in dart

I am receiving json string through an API from a website. However, the json format sent to me is not the format i want to work with. I want to change the received json string format to the desirable format.
This is the format i received:
{"symbols_returned":147,"base":"USD","data":{"AED":
3.673010,"AFN":75.392000,"ALL":109.685000}}
This however is the format i desire to have:
{"symbols_returned":147,"base":"USD","data":{"AED":"3.673010","AFN":"75.392000","ALL":"109.685000"}}
The difference between the former and latter is the presence of quotation marks on all the numeric currency values in the second json string. It can be seen that the first json string does not have quotes on the numeric currency values.
My question is how can i programmatically turn the first json string to the second json string format using dart programming language. Any help will be appreciated. Thanks
you need to parse the json data before you can use it.
you need to use the json package from dart:convert do do this
import 'dart:convert';
final yourResult = json.decode(API_RESULT);
print(yourResult) // {"symbols_returned":147,"base":"USD","data":{"AED":"3.673010","AFN":"75.392000","ALL":"109.685000"}}
will parse the json and preserve the data types and make that a Map

Converting hex to ByteString in Swift

We are trying to connect to Periodic's API using Swift 5. In order to do that, part of the process is encoding a concatenated string in HMAC SHA-256. In our code, we accomplish this by the following code:
let hmac = premac.digest(.sha256, key: "API KEY")
Which is using the SwiftCrypto library to accomplish this. According to Periodic's CTO, we are getting close but the issue is that this function's output is giving us a HEX version when we really need the bytestring level.
We are unsure how to proceed.

Base64 decoding of MIME email not working (GMail API)

I'm using the GMail API to retrieve an email contents. I am getting the following base64 encoded data for the body: http://hastebin.com/ovucoranam.md
But when I run it through a base64 decoder, it either returns an empty string (error) or something that resembles the HTML data but with a bunch of weird characters.
Help?
I'm not sure if you've solved it yet, but GmailGuy is correct. You need to convert the body to the Base64 RFC 4648 standard. The jist is you'll need to replace - with + and _ with /.
I've taken your original input and did the replacement: http://hastebin.com/ukanavudaz
And used base64decode.org to decode it, and it was fine.
You need to use URL (aka "web") safe base64 decoding alphabet (see rfc 4648), which it doesn't appear you're doing. Using the standard base64 alphabet may work sometimes but not always (2 of the characters are different).
Docs don't seem to consistently mention this important detail. Here's one where it does though:
https://developers.google.com/gmail/api/guides/drafts
Also, if your particular library doesn't support the "URL safe" alphabet then you can do string substitution on the string first ("-" with "+" and "_" with "/") and then do normal base64 decoding on it.
I had the same issue decoding the 'data' fields in the message object response from the Gmail API. The Google Ruby API library wasn't decoding the text correctly either. I found I needed to do a url-safe base64 decode:
#data = Base64.urlsafe_decode64(JSON.parse(#result.data.to_json)["payload"]["body"]["data"])
Hope that helps!
There is an example for python 2.x and 3.x:
decodedContents = base64.urlsafe_b64decode(payload["body"]["data"].encode('ASCII'))
If you only need to decode for displaying purposes, consider using atob to decode the messages in JavaScript frontend (see ref).
I found whilst playing with the API result, once I had drilled down to the body I was given an option to decode in the available methods.
val message = mService!!.users().messages().get(user, id).setFormat("full").execute()
println("Message snippet: " + message.snippet)
if(message.payload.mimeType == "text/plain"){
val body = message.payload.body.decodeData() // getValue("body")
Log.i("BODY", body.toString(Charset.defaultCharset()))
}
The result:-
com.example.quickstart I/BODY: ISOLATE NORMAL: 514471,Fap, South Point Rolleston, 55 Faringdon Boulevard , Rolleston, 30 May 2018 20:59:21
I coped the base64 test to a file (b64.txt), then base64-decoded it using base64 (from coreutils) with the -d option (see http://linux.die.net/man/1/base64) and I got text that was perfectly readable. The command I used was:
cat b64.txt | base64 -d

Getting emailaddress out of string

How can I get the email address out of a string like:
def emailAddress="john#doe.com <\john#doe.com\\>"
so that I can use it in a call to Contactperson.findByEmailAddress(variable)
JavaMail provides a class for representing email addresses that can parse strings in the format you have. Take a look at javax.mail.internet.InternetAddress.
Grails has a mail plugin that will automatically make JavaMail available.
A simple solution is
Contactperson.findByEmailAddress(emailAddress.split('<')[0])
But you need to do some validation work first to avoid format errors.
I'm assuming the email you need to compare is inside the brackets:
Contactperson.findByEmailAddressIlike('%<${variable}>%')
You'll probably need to escape the special characters depending on your database.

Send a special parameter via RequestBuilder POST on GWT

I am a beginner of GWT.
In my application, i need to post parameter which of value is a URL such like a following string.
'http://h.com/a.php?code=186&cate_code=MV&album=acce'
As you can see it, it includes character sequences '&cat_code='.
As i know, &parametername=value is form of one parameter!...
Because of this, a PHP file on my server side, only receives a following string,
'http://hyangmusic.com/Ticket_View.php?code=186'
How could i do in this situation... i want to receive a full URL as parameter on the server side PHP.
Please help me.
Thanks in advance.
my code.
String name = "John";
String url = "http://h.com/a.php?code=186&cate_code=MV&album=acce";
String parameter = "name="+name+"&url="+url;
builder.setHeader("Content-Type","application/x-www-form-urlencoded");
builder.sendRequest(parameter,
new RequestCallback() {
}
Use URL.encodeQueryString(url) so that your & is turned into a %26 (26 being the hexadecimal representation of the UTF-8 encoding of &)