sha - Do you have to escape back slashes or do any special encoding with Rs Digest function within the Alteryx R tool -
i'm using alteryx r tool sha256 hash calculations, i'm running trouble 1 of inputs. i'm trying produce sha256 hash following input:
post\n/\n\ncontent_type:\nhost:dynamodb.us-east-1.amazonaws.com\nx-amz-date:20150707t201951z\nx-amz-target:dynamodb_20120810.createtable\n\ncontent_type;host;x-amz-date;x-amz-target\n09a8bcdeea1d20631f887235820bbff0a614679080a2e74a89ceb1a1bcc71b44 my r function is:
digest('post\n/\n\ncontent_type:\nhost:dynamodb.us-east-1.amazonaws.com\nx-amz-date:20150707t201951z\nx-amz-target:dynamodb_20120810.createtable\n\ncontent_type;host;x-amz-date;x-amz-target\n09a8bcdeea1d20631f887235820bbff0a614679080a2e74a89ceb1a1bcc71b44', algo='sha256', serialize = false) and hash produced r is:
7fe2c3fc70134481217952f27bb5f4af95193645903ba3a6d4d7ad45c3adade1 this value not correct. correct value is:
9a493c643eeb736decc195a8e0e84e08f45a00bdbc21feaafa94be5f0f299af0 you can see correct value calculated below using python;
i've calculated correct value using r command line tool. leads me believe alteryx somehow altering input , result producing wrong output. has come across or know possible workaround.
my r tool script follows:

where c =
post\n/\n\ncontent_type:\nhost:dynamodb.us-east-1.amazonaws.com\nx-amz-date:20150707t201951z\nx-amz-target:dynamodb_20120810.createtable\n\ncontent_type;host;x-amz-date;x-amz-target\n09a8bcdeea1d20631f887235820bbff0a614679080a2e74a89ceb1a1bcc71b44
if replace \ \\ in input string (in regular r or python), digest value starting "7fe..." suggests indeed, alteryx doing in hand-off r.
a work-around run through alteryx base64 tool prior r tool, have r tool base 64 decode, like:
library("digest") library("catools") df <- as.data.frame(read.alteryx("#1", mode="data.frame")) df$out <- digest(base64decode(as.character(df$b64),what="character"), algo='sha256', serialize = false) write.alteryx(df, 1) while not ideal, give correct output starting "9a493..."
Comments
Post a Comment