I´m about to introduce 2FA and use QRcode.js to generate a QR code from the secret key to be scanned by the 2FA apps.
$('#totpQR').empty();
new QRCode(document.getElementById('totpQR'),secretkey);
$('#totpQRContainer').css('display','inline');
$('#totpQR').attr('title', 'otpauth://totp/'+encodeURIComponent(username)
+ location.hostname.replace(/^(.*\.)?(\b[\w-]+\.[a-z]+)$/, '#$2?secret=')
+ secretkey
);
Both GoogleAuthenticator and Authy seem to be picky there; they reject the code saying "The QR code is invalid" or similar. When I use a proper QR reader to scan the same QR, the key from the URL (otpauth://totp/username#sitename.tld?secret=secretkey or otpauth://totp/sitename?secret=secretkey or otpauth://totp/username#sitename.tld?secret=secretkey&digits=6&issuer=SiteName&period=30) comes out correct.
Googling for the issue gave me no results.
Can anyone tell me what parameters I should use to generate my QR or do I have to experiment?
I guess that there´s no mistake in the URL?
The problem was in my code indeed: I created the QR from the key, not from the whole URL:
$('#totpQR').empty();
var url='otpauth://totp/'+encodeURIComponent(username)
+ location.hostname.replace(/^(.*\.)?(\b[\w-]+\.[a-z]+)$/, '#$2?secret=')
+ secretkey
;
new QRCode(document.getElementById('totpQR'),url);
$('#totpQRContainer').css('display','inline');
$('#totpQR').attr('title',url);
Related
I'm trying to create a way to check whether a given email (either from Outlook itself or an MSG file) is a sent, received or a draft email. I got the bit to compare if it was sent or received somewhere else and that works fine but it's the part that determines if it's a draft or not that is the issue. Below is what I have currently.
L-EMAIL = Aspose.Email.Mapi.MapiMessage:FromFile(P-FILENAME).
L-EMAIL-FLAG = Integer(L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_MESSAGE_FLAGS]:ToString()).
IF L-EMAIL-FLAG = 8 THEN
L-EMAIL-STATUS = "DRAFT".
ELSE
IF L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_RECEIVED_BY_ENTRYID] = ? THEN
L-EMAIL-STATUS = "SENT".
ELSE
L-EMAIL-STATUS = "RECEIVED".
If there's no attachments to the emails, it works fine since the value of a draft email is always 8 but as soon as you add attachments, it gets all weird with the values so I can't get a range down (I've gotten values like 24 and 242613 while a sent email with an attachment has a value of 49). Anyone know a smarter way of telling if it's a draft or not?
I never had a good experience working with Outlook and Progress internally... what I've managed to accomplish on my project was to create a custom DLL with C# and integrated it on my system.
So, I have an char that triggers some procedures inside my DLL and sends and receives emails (saves as .msg), making my Progress code a lot more easier to manage.
In your case, you should try something like this:
Outlook MailItem: How to distinguish whether mail is incoming or outgoing?
Solution I found was to use a C# DLL to convert the email to an Outlook mail item using the interop:
public bool IsDraft(string path)
{
Outlook.Application oApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
Outlook.MailItem email = oApp.Session.OpenSharedItem(path) as Outlook.MailItem;
bool isSent = email.Sent;
Marshal.ReleaseComObject(email);
email = null;
return !isSent;
}
I had to release the email object so that code further on wouldn't break.
The PidTagMessageFlags property value is a bitmask of flags. This means a bitwise operator must be applied to check a specific flag value.
IF L-EMAIL-FLAG = 8 THEN
Please replace above line with following line of code. Hope this helps you.
IF (L-EMAIL-FLAG AND 8) = 8 THEN
I work with Aspose as Developer Evangelist.
I am trying to integrate PayU in my website, I have successfully done the payment api part. Now I am trying to call verification api of transaction. I have followed all the steps from documentation.
Method POST:https://test.payu.in/merchant/postservice?form=2
Image
I am getting, Sorry Some Problem Occurred without any proper error message.
I am stuck on this. Please help.
Any help or comment will be highly appreciated.
My code: Function to make string(in expected format given in the documentation) and Hash using SHA256
{ string command = "verify_payment";
string finalStringToBeHashed = PAYU_KEY +"|"+ command + "|" + transactionId + "|" + PAYU_SALT;
string hash = _iPayUServices.GetSHA256(finalStringToBeHashed);
return Ok(( hash, finalStringToBeHashed));
}
and I am confident that my GetSHA256() function is correct. (As it working for payment api's).
Instead of https://test.payu.in/merchant/postservice?form=2 URL,
use https://info.payu.in/merchant/postservice?form=2.
Actually They are upgrading their documentation, so many things are missing as of now. Hopefully, they will add this soon.
I'm trying to program a script for hubot, and it seems I have an unclosed string. The contents will appear in an html format with emoji like :smile: etc. It isn't compiling in Cofeescript. I'm new to javascript, any help would be appreciated.
The error I got is
ERROR Unable to load /var/discourse/avebot/scripts/test: /var/discourse/avebot/scripts/test.js:5
msg.reply("Hello! I’m Avebot, and I will be your guide throughout your training. :smile: <br>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:51:7)
and the script is:
robot.hear(/hi bot/, function(msg) {
msg.reply("Hello! I’m a bot, and I will be your guide your training. :smile: <br>
<br>After finishing this training, you will be able to do x y z. :tada:<br>
Are you ready? If so, let me know you are ready by replying 'yes I’m ready!'");
//Start a dialog with the user that sent this message.
var dialog = switchBoard.startDialog(msg);
//Provide choices for the next step, wait for the user.
dialog.addChoice(/yes/, function(msg2){ msg2.reply('Okay');}
dialog.addChoice( /no/, function(msg2){ msg2.reply("Okay, I'll wait"); }
//The dialog will expire after 30 secods.
});
You need to escape the ' in I'm Avebot by putting a backslash before the apostrophe (so it's I\'m Avebot).
Check out this site here for more information on JS escape sequences.
in order to define multiline strings in Javascript you can use backslash \ before new lines
msg.reply("Hello! I’m a bot, and I will be your guide your training. :smile: <br>\
<br>After finishing this training, you will be able to do x y z. :tada:<br>\
Are you ready? If so, let me know you are ready by replying 'yes I’m ready!'");
i registered in https://my.telegram.org/apps and got api_hash and api_id and public key ,now i want to use this function https://core.telegram.org/method/auth.sendCode
auth.sentCode#efed51d9 phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
auth.sentAppCode#e325edcf phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
---functions---
auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode;
Query example
(auth.sendCode "79991234567" 1 32 "test-hash" "en")
=
(auth.sentCode
phone_registered:(boolFalse)
phone_code_hash:"2dc02d2cda9e615c84"
)
d16ff372 3939370b 33323139 37363534 00000001 00000020 73657409 61682d74 00006873 e77e812d
=
2215bcbd bc799737 63643212 32643230 39616463 35313665 00343863 e12b7901
how can i use this query example?
and what is this binaries? ==> "d16ff372 3939370b 33323139 ...."
You can't directly start to send queries to Telegram. Creating api_hash and api_id is a basic step to start with Telegram API. Hope you know that Telegram uses its own protocol called 'MTProto'. You can get the detailed discription in Telegram's official website.
As per Telegram Protocol, the Client and Server shares the 'Authorization Key' (which is used for encryption and decryption) using Diffie-Hellman algorithm. For sample please see https://core.telegram.org/mtproto/samples-auth_key. After creating the authorization key successfully, we can start to call Telegram APIs which is called as RPC queries.
You can also refer https://github.com/ex3ndr/telegram-api for implementation.
The hexadecimal data in the example is nothing but the query made by following the algorithm.
You need to start from making a valid Telegram AuthKey.
The patterns and functions you build up along the way while doing this will help you towards building the rest of your Telegram API.
You can start with this here: https://stackoverflow.com/a/32809138/44080
And them work up, step by step until you have the AuthKey as described in these links
https://core.telegram.org/mtproto/auth_key
https://core.telegram.org/mtproto/samples-auth_key
Part of the problem you will initially face is the documentation.
Working through this step by step and getting familiar with the authors writing style is a big help too.
I've opened up a twilio trial account. I want to use my verified called ID number in my asp.net application instead of buying a new twilio number. But I don't know how to use it. Here are my codes,
public ActionResult SendSms()
{
string ACC_SID = ConfigurationManager.AppSettings["ACC_SID"];
string AUTH_TKN = ConfigurationManager.AppSettings["AUTH_TKN"];
TwilioRestClient client = new TwilioRestClient(ACC_SID, AUTH_TKN);
client.SendMessage("+8801941234567", "+8801671234567", string.Format("This is a test message!"));
return RedirectToAction("SmsView");
}
Nothing happened with it. How can I use my called ID to send sms?
I faced the same scenario while I was working on Twilio first time and at that time I used below steps to make things workable.
1) First of all I would suggest please add Try{} catch{} block in your SendSMS function. this will give you idea like SendMessage worked correctly.
2) In twilio we need to register mobile no before send SMS.
3) if your function works fine(no error occur) then in Twilio there is LOG tab where you can see weather your SMS send correctly or not.
Twilio developer evangelist here.
Jinesh's answer has some useful parts, like using a try/catch block to see errors.
However, the problem is that you are trying to send an SMS from your own number, not from a Twilio number. When sending SMS, you can only send from Twilio numbers. Please see this page for details on why.
You should have got a Twilio number when you signed up. Try using that number as the From number instead.