HI,
I am interested in Radzen, it looks like I will use it, but I need to be confirmed whether Radzen supports this facility.
I need to generate Signature and unixtime format to send request to a webservice as HEADER
Is Radzen support this methode?
FYI: https://dvlp.bpjs-kesehatan.go.id/VClaim-Katalog/
Link above is catalog that I want to access in my application.
Please confirm if Radzen can handle this case.
Thank you very much.
enchev
April 17, 2020, 6:21am
2
I'm not sure I understand your question. You want to call a service from your app? Radzen Blazor applications are normal Blazor apps that can be extended with partial classes. Evenrything that works in other MVC/Blazor applications will work in Radzen applications as well.
Thanks for your reply,
Actualy when you take alook into the link I gave, I am sure you gonna know what I mean .
I really need this confirmation before I decide to buy Radzen.
Thank you.
enchev
April 17, 2020, 9:28am
4
Already visited the link you've posted and I still do not understand your question. Can you clarify? Especially this part:
Yes,
I have to send RESTrequest to the Webservice with parameters: ConsId, UnixTime dan Signature with generate by using ConsId and ScreetKey they provided for me.
What I am asking is Radzen also can generate signature (SHA256)?
Thank you.
enchev
April 17, 2020, 9:40am
6
Surya_Dandes:
SHA256
Radzen does not generate such things since they are not needed by default however you can add your own custom code to generate it.
//--------------------------------------PHP---------------------------------
<?php
$data = "testtesttest";
$secretKey = "secretkey";
// Computes the timestamp
date_default_timezone_set('UTC');
$tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
// Computes the signature by hashing the salt with the secret key as the key
$signature = hash_hmac('sha256', $data."&".$tStamp, $secretKey, true);
// base64 encode…
$encodedSignature = base64_encode($signature);
// urlencode…
// $encodedSignature = urlencode($encodedSignature);
echo "X-cons-id: " .$data ." ";
echo "X-timestamp:" .$tStamp ." ";
echo "X-signature: " .$encodedSignature;
?>
//----------------------------------JAVA--------------------
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.springframework.security.crypto.codec.Base64;
public class BpjsApi {
public static void main(String[] args) throws GeneralSecurityException, IOException {
String secretKey = "secretKey";
String salt = "0123456789";
String generateHmacSHA256Signature = generateHmacSHA256Signature(salt, secretKey);
System.out.println("Signature: " + generateHmacSHA256Signature);
String urlEncodedSign = URLEncoder.encode(generateHmacSHA256Signature, "UTF-8");
System.out.println("Url encoded value: " + urlEncodedSign);
}
public static String generateHmacSHA256Signature(String data, String key) throws GeneralSecurityException {
byte[] hmacData = null;
try {
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(secretKey);
hmacData = mac.doFinal(data.getBytes("UTF-8"));
return new Base64Encoder().encode(hmacData);
} catch (UnsupportedEncodingException e) {
throw new GeneralSecurityException(e);
}
}
}
above is PHP and JAVA script, is Radzen can run that script?
enchev
April 17, 2020, 9:48am
8
Radzen generates .NET Core C# app - you cannot run PHP scripts nor Java. You can create something similar using C#.
Thank you Eenchev, I got the point.