Edit in JSFiddle

// step 1 - initialize
var worker =  new encrypter({
    key: {
        contents: '-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA13PTo+cgJMtUc68br9CDO1+yX9L20QcBCv3HfA1lCkO9cLfi27wZ+scwISTpNXOM8MLRq3iTTHFF7JYLrk0ztU6E3fCqut7M/0YyHqwHbOZaw/msFBRkkfmvWq0UXNwksi7T26Yn7OHAVMyHuMFidz+ggQxsIW9UVryHwvkWA+qdqcMxRy+kdw+UyFGWuSJgDEIjChffICmHiU2T+NEXQp9ChjxLhvCVj6YdRlsM+EbZynPFReoIbLyI9FjBIQ1kIgBoJtgEm1X4j5l6XhKJ2gwJB4blWStGKjbrTkPG4tqd4ZjtiapQliMuYhz3B5kWvCKimCHZmbB3OM3bWteVGQIdJ3a8ScO3MmxnCLhHknth+a2pFcIOULGfR3LZr31ihFN/uzODDMU+z7AyrH9L4F1/3UJuUtfpz0xDPMK9zhOe0j6JQJrlLEMKSuX2CONTv39dbUqQVW9hOFpYkjZw70zlHCiJbi53Qpwjqt355QnUDlcxZQgmpF916ZmBMsRcyZykFEdhZXFVhCRqJ6exx/428RSe0yC1mbIqm7Pmogjhwn9yKa5yIA7FaaLFQtJfzKQx4reK8+qtBJ6Wl3tNZa9zjzsY8HRvjmtJHfGswGvoBNEP+hWh1eAgEh7MrEKqqdU4KBwbJv7OUBIUGjm/QiqrQzRQzETXTdTonbnodpkCAwEAAQ==-----END PUBLIC KEY-----',
        identifier: 'public-key-0001'
    }
});

worker.setCurrentPaymentMethod('CC');
var fields = worker.getCurrentPaymentMethod().getFields();

// step 2 - fill data (JS lib way)
var details = {}; // will be filled
for (var i in fields) {
    details[i] = fields[i].getDefaultValue();
}

details.RecurringEnabled = false;
details.Country = "Romania";
details.HolderName = "Shopper Test";
details.CardType = "visa";
details.CardNumber = "4111111111111111";
details.CCID = "123";
details.ExpirationMonth = '11';
details.ExpirationYear = 2017;

// step 3 - encrypt
var encryptedDetails = worker.getEncryptedDetails(JSON.stringify(details));

document.body.insertAdjacentHTML("beforeend", JSON.stringify(encryptedDetails));