Cody

# Problem 44959. RSA encryption using public key

Solution 1924114

Submitted on 6 Sep 2019 by Tim
• Size: 27
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
message = 'I like to swim!'; n='418336393847020647250825879743341651032293545176800777981294580200903315345456262337972725306797613061'; out = '158037161019988039882393476857386648994978438821991287680442802412825849535544067751541256843540494019'; assert(isequal(RSA_Encrypt(message,n),out))

2   Pass
message = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.'; n='44842008376687803367401704855862174057751658874412319214254366772513580664834338103711248053800336314605433363839051280089244765499067546768593375603554906634041005882836398715141891796137918851678901692978242458027064144613729242304549721699241688731628849316717564354846304644497408201649639245333007226999680183209765262168096747256549932760714835163829498814356014506466022681051474161134416048209239076204778228261950266231966892099194904195589855692846886804440024833800891898474520523721428667143505915995217245366095168045283186412220277535584022415882288464175935131208288146822299727657938865855853054174274144036081729604573534323903573564345990066095029031133576597298513883268061041004553754062342541175017746399640362184228727837219293246060058323563065371426108553463224921179093569734439828568435658070810483844709529476015493154462587917722806971578721201741643550136095893915598053953011321347017522943202801820158823344592288227452688958887872572522782675644714289349442555731461112275849176682816627205790162163242534462778708459909915826953853537650009043468930450287584181263070727575137424307931682948818963610116434419852585517456098152109913486868606969385133300794635427715727859479612757775192862801547635779921771426233897718528292667112148507798722127322607462037572360649156150337532940752245966765201596748120586383127825681873289878451591957019880886587602576426267683951317718936847177641679183717321862429721190212389237395890951104472937261743929446841800523276218816808066432194473964294708564511969507018959711475230849760902049071415838600456901108854663197095849833602808088094456341330276320302662577163562657750920481798540333412112880539002713127873625438212479154166226846436038698572615482646490520911334607730484144343834476612603467400722323562384577281087071440008144012534847478593412147312743274523095010025887231371129897419306984829625295595332434377173711414555784685658774002600022998291909172576630780759729269867715816511099791566815282862210319017784751883446582453959'; out = '23055330962704323769878549529115024711681463755869375992447358448257597289666397997393945478297323372847937346015110864832142828615195632399869833059964395947034849804307978652470092440225822549097020437344501330227622390881049097656181781980124142659454562923055085607225529541369345564097544873012395850084756321027482195140106724706102857159831541577386517426252851135917933602432485339455137853480425755360413522537180403768732770990453717801905433194599201771294559164174484366213507079896512750859909040228686293902666244968559905065091421969981123917913807285202549025830873320919273470513619143052127674709353494599047667391749001044180280253098309127910967801244777547067797257847396027373615105278074126621948502699483945442597921239032762535839481741386676784123570880434889025648597593711911259097408384527597630246903648267481820555872340696607290773027177673329986283293168575528258578575033034179306629426942699054620008867304832513427178319015491321861291086200676826846740503213061372327825278234127270730394825241275398344604061667061892125034848354745243512927194104643800196788262228848172689053393410972717679060779374106225778531311917434399927265718394014531619654762559111657295163989321031700962115070401533540746801357628868609255941469541707984326602981168016264720519340003693219403163278843126513912057794102645161814569893320900148891952732032827189210372803453777673309727629845360314416264926243414888253428149538146304399700653423118791724424837155323935319171814705469113037576054893140065594406360362408167462563925199225169055130480445976569760198217276692195730775524801021060293503580957364539210146595506177369243830063105693396808209631409860229448190041996912370291877581261016834769083953407597967437841733812344230896457097759403613339974363380556576775192238298546579676296359906794868505900966056565863994904406875527092603782089107591766239203672780399852597928423220774857864301715176837587724591257928112610743311445186658958007825888475800717425136849205837547536117562642680'; assert(isequal(RSA_Encrypt(message,n),out))

3   Pass
message = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.'; n='2044371069952561243871813747701535503388267616657953475148898181142012590397809234167373308955772082860082985954286137615597515257087506574051530104475374974920093127841789408014496870693507622812332673504654584870100580476794800708440785082437228308551107726064054828640053321250498545183042994878498928173976370185712833904492317580152665428272199317847097773542066059565512439224992672101163367819'; out = '99761240327251194937668282784881225946299704960682605372368300120848092908591455333889649815054891832920433772438140697229743047905660648016064750862552787515723449901585029566883857331537912668878918706229773460108043130645834201085405226084010413433457258525704626839479467337463012332940952234541291286602023412313079939518264986360860440514106228995186076871512459300140814669747884371890194124'; assert(isequal(RSA_Encrypt(message,n),out))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!